﻿using Grpc.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace GrpcConsoleApp
{
    public class Program
    {
        /// <summary>
        /// PS C:\Users\liuziyang\source\repos\GrpcConsoleApp&gt; C:\Users\liuziyang\source\repos\GrpcConsoleApp\packages\Grpc.Tools.2.38.1\tools\windows_x64\protoc.exe -IGrpcConsoleApp --csharp_out GrpcConsoleApp GrpcConsoleApp\Proto\helloworld.proto --grpc_out GrpcConsoleApp --plugin=protoc-gen-grpc=C:\Users\liuziyang\source\repos\GrpcConsoleApp\packages\Grpc.Tools.2.38.1\tools\windows_x64\grpc_csharp_plugin.exe
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            Channel channel = new Channel("10.2.32.104:9090", ChannelCredentials.Insecure);
            var client = new HelloWorldService.HelloWorldServiceClient(channel);

            for(var i = 0; i < 10; i++)
            {
                var replay = client.sayHello(new Person() { FirstName = "zy", LastName = "L" });
                Console.WriteLine($"{replay.Message}");
                Thread.Sleep(1000);
            }

            channel.ShutdownAsync().Wait();
            Console.ReadLine();
        }
    }
}
